package com.gubatian.dfs.namenode.server;

/**
 * Name node 核心启动类
 *
 * @author: gubatian
 * @create: 2021-09-22 18:55
 */
public class NameNode {
    private volatile Boolean shouldRun;
    /**
     * 负责管理元数据的核心组件
     */
    private FSNameSystem fsNameSystem;
    /**
     * name node 的 RPC 的服务接口，可以响应请求
     */
    private NameNodeRpcServer nameNodeRpcServer;
    public NameNode() {
        shouldRun = true;
    }

    public void initialize() {
        this.fsNameSystem = new FSNameSystem();
        this.nameNodeRpcServer = new NameNodeRpcServer(fsNameSystem);
        nameNodeRpcServer.start();
    }

    /**
     * 让name node运行起来
     */
    private void run() {
        try {
            while (shouldRun) {
                Thread.sleep(10 * 1000);
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        NameNode nameNode = new NameNode();
        nameNode.initialize();
        nameNode.run();
    }
}